from pylons import config
from sqlalchemy import Column, MetaData, ThreadLocalMetaData, Table, types
from sqlalchemy.orm import mapper, relation
from sqlalchemy.orm import scoped_session, sessionmaker

def createMetaData():
    return MetaData()

# Global session manager.  Session() returns the session object
# appropriate for the current web request.
Session = scoped_session(sessionmaker(autoflush=True, transactional=True,
                                      bind=config['pylons.g'].sa_engine))

# Global metadata. If you have multiple databases with overlapping table
# names, you'll need a metadata for each database.
metadata = MetaData()

## Define a table.
#table1 = Table("things", metadata,
#    Column("id", types.Integer, primary_key=True, autoincrement=True),
#    Column("name", types.String, nullable=False),
#    )
#
#class Thing(object):
#    pass
#
## Map each class to its corresponding table.
#mapper(Thing, table1)